package com.xbongbong.parent.interfaces.logger;

import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;
import java.util.Objects;

/**
 * @author: yingjianfeng
 * @date: 2022/4/13 16:59
 * @description:
 */
@Component
public class OperationLogFactory {
    @Resource
    private Map<Integer, OperationLogHandle> operationLogHandleMap;
    @Resource
    private Map<Integer, PushNotifyLogHandle> pushNotifyLogHandleMap;
    @Resource
    private Map<Integer, FocusOperationLogHandle> focusOperationLogHandleMap;
    @Resource
    private Map<Integer, ArchiveOperationLogHandle> farchiveOperationLogHandleMap;
    /**
     * 获取操作处理实现类
     * date: 2022/4/22 3:46 下午
     * @Author yingjf
     * @param saasMark:
     * @param businessType:
     */
    public OperationLogHandle getOperationLogHandle(Integer saasMark, Integer businessType) {
        if (Objects.equals(SaasMarkEnum.PAAS.getCode(), saasMark)) {
            return operationLogHandleMap.get(XbbRefTypeEnum.PAAS.getCode());
        } else {
            return operationLogHandleMap.get(businessType);
        }
    }
    /**
     * 获取操作跟进提醒实现类
     * date: 2022/4/22 3:47 下午
     * @Author yingjf
     * @param saasMark:
     * @param businessType:
     */
    public PushNotifyLogHandle getPushNotufyLogHandle(Integer saasMark, Integer businessType) {
        if (Objects.equals(SaasMarkEnum.PAAS.getCode(), saasMark)) {
            return pushNotifyLogHandleMap.get(XbbRefTypeEnum.PAAS.getCode());
        } else {
            return pushNotifyLogHandleMap.get(businessType);
        }
    }
    /**
     * 获取操作关注实现类
     * date: 2022/4/24 4:45 下午
     * @Author yingjf
     * @param saasMark:
     * @param businessType:
     */
    public FocusOperationLogHandle getFocusLogHandle(Integer saasMark, Integer businessType) {
        if (Objects.equals(SaasMarkEnum.PAAS.getCode(), saasMark)) {
            return focusOperationLogHandleMap.get(XbbRefTypeEnum.PAAS.getCode());
        } else {
            return focusOperationLogHandleMap.get(businessType);
        }
    }

    /**
     * 获取操作归档实现类
     * date: 2022/4/24 4:45 下午
     * @Author yingjf
     * @param saasMark:
     * @param businessType:
     */
    public ArchiveOperationLogHandle getArchiveLogHandle(Integer saasMark, Integer businessType) {
        if (Objects.equals(SaasMarkEnum.PAAS.getCode(), saasMark)) {
            return farchiveOperationLogHandleMap.get(XbbRefTypeEnum.PAAS.getCode());
        } else {
            return farchiveOperationLogHandleMap.get(businessType);
        }
    }
}
